package executor;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author tongchen
 * @create 2023-01-21 13:46
 */
public class TestThread {
    public static void main(String[] args) {
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(5, 10, 60, TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(10),  new ThreadPoolExecutor.AbortPolicy());
        //jdk提供的自动创建方法，我们只管建立循环提交任务即可
        for (int i = 0; i < 100; i++) {
                int taskId=i;
            threadPoolExecutor.submit(()->{
                System.out.println(taskId);
            });
        }

    }
}
